package client;
import client.*;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.rmi.Naming;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JLabel;

import server.CompanyInterface;
import server.InvestComInterface;
import server.PersonInterface;
import server.StaffInterface;
import java.awt.Font;

public class EnterDeveCom_GUI extends JFrame {
	public static int ComID;

	private JPanel contentPane;

	/**
	 * Launch the application.
	 *//*
	public static void main(String [] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					EnterDeveCom_GUI frame = new EnterDeveCom_GUI(ComID);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public EnterDeveCom_GUI(int CID) {
		this.ComID=CID;
		setTitle("\u5F00\u53D1\u516C\u53F8");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setToolTipText("\u5927\u65F6\u4EE3");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblxxx = new JLabel("欢迎来到本开发公司！");
		lblxxx.setFont(new Font("宋体", Font.PLAIN, 18));
		lblxxx.setBounds(53, 10, 248, 39);
		contentPane.add(lblxxx);
		
		final Person per=new Person();
		Configuration config=new Configuration();
		String rmiAddress=config.getRmiAddress();
		try
		{
			
		final StaffInterface SI=(StaffInterface) Naming.lookup(rmiAddress+"Staff");
		final PersonInterface PI=(PersonInterface)  Naming.lookup(rmiAddress+"Person"); 
		final CompanyInterface CI=(CompanyInterface)  Naming.lookup(rmiAddress+"Company"); 
		
		if(PI.getComID(per.getPID())==0)
		{
		JButton button = new JButton("\u5E94\u8058");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try{
					if(PI.setComID(per.getPID(), ComID) && PI.apply(per.getPID(), SI.getPost(ComID, 1)) ){
						int staffNum=CI.getStaffNum(per.getPID());
						if(CI.setStaffNum(ComID, staffNum+1)){
							DeveApplySuc_GUI deveapplysuc =new DeveApplySuc_GUI();
							deveapplysuc.setLocationRelativeTo(null);
							deveapplysuc.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
							deveapplysuc.setVisible(true);
							dispose();
						}
					}
				}
				catch (Exception e1)
				{
					e1.printStackTrace();
				}
			}
		});
		button.setBounds(159, 90, 120, 23);
		contentPane.add(button);
		}
		else{
			
		if(PI.getComID(per.getPID())==ComID)
		{
		JButton button_1 = new JButton("\u8FDB\u5165\u516C\u53F8");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				DeveComPost_GUI devecompost =new DeveComPost_GUI();
				devecompost.setLocationRelativeTo(null);
				devecompost.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
				devecompost.setVisible(true);
				dispose();
				
			}
		});
		button_1.setBounds(159, 130, 120, 23);
		contentPane.add(button_1);
		
		}
		else		
		{
			JOptionPane.showMessageDialog(null, "You have had a job!");
		}
		}
		
		JButton button_1 = new JButton("\u79BB\u5F00\u516C\u53F8");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		button_1.setBounds(159, 170, 120, 40);
		contentPane.add(button_1);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}
